<?php
namespace Admin\Controller;
use Think\Controller;
class NavController extends Controller {
      public function index(){
        $page = $_REQUEST['p'] ? $_REQUEST['p'] : 1;
        $pageSize =5;
        $navs = D("Nav")->getNavs($data,$page,$pageSize);
        $navsCount = D("Nav")->getNavsCount($data);

        $res = new \Think\Page($navsCount, $pageSize);
        $pageRes = $res->show();
        $this->assign('pageRes', $pageRes);
        $this->assign('navs',$navs);
         $this->display();
 	}
        public function add(){
 if($_POST) {
            if(!isset($_POST['name']) || !$_POST['name']) {
                return show(0,'导航名名不能为空');
            }

/*            if($_POST['menu_id']) {
                return $this->save($_POST);
            }*/
            $NavId = D("Nav")->insert($_POST);
            if($NavId) {
                return show(1,'新增成功',$NavId);
            }
            return show(0,'新增失败',$NavId);

        }else {
            $this->display();
        }
        //echo "welcome to singcms";
    }



 }	